import { http } from "@/utils/http";
import type { ArticleVO } from '@/types/article'
import type { PageR } from "@/types/api";

/** 分页查询文章 */
export const getArticleList = (params: {
  page?: number;
  size?: number;
}) => {
  return http.get<PageR<ArticleVO[]>>("articles/list", { params });
};


/** 增加文章浏览量 */
export const addArticleView = (id: number) => {
  return http.post(`articles/${id}/view`);
};

/** 获取文章详情 */
export const getArticleDetail = (id: number) => {
  return http.get<ArticleVO>(`articles/detail/${id}`);
};

/** 根据标签ID查询文章 */
export const getArticlesByTagId = (
  tagId: number,
  params: {
    page?: number;
    size?: number;
  }
) => {
  return http.get<PageR<ArticleVO[]>>(`articles/tag-id/${tagId}`, { params });
};

